<template>
  <div class="header-container">
    <div class="l-content">
      <el-button style="margin-right:10px" @click="handleMenu" icon="el-icon-menu" size="mini"></el-button>
      <!-- 面包屑 -->
      <el-breadcrumb separator="/">
        <el-breadcrumb-item style="font-size:12px; " v-for="item in tags" :key="item.name" :to="{ path: item.path }">{{ item.label }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="r-content" >
      <el-dropdown @command="handleClick">
        <span class="el-dropdown-link">
          <img :src="userimg" alt="" class="userimg">
        </span>
        <el-dropdown-menu  slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item command="cancel" >退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>
<script>
import {mapMutations,mapState} from 'vuex'
import Cookie from 'js-cookie'
export default {
  data() {
    return {
      //用户头像
      userimg: 'https://ts1.cn.mm.bing.net/th/id/R-C.aff2319c74a600929a3a97321c4d6e1c?rik=s468D3gw3bhZ1w&riu=http%3a%2f%2ftupian.qqw21.com%2farticle%2fUploadPic%2f2017-2%2f20172262062516908.jpg&ehk=DLY6M1onZcxnhBW5yszZ%2b6v%2bmAiwmH6fahBVBOAKWv0%3d&risl=&pid=ImgRaw&r=0'
    }
  },
  computed: {
     ...mapState({
      tags:state => state.tab.tabsList
     })
  },
  
  methods: {
    // ...mapMutations( 'tab', ['collapseMenu']),
    handleMenu() {
      this.$store.commit('collapseMenu')
      // console.log(this.isCollapse);
    },
    //退出登录
    handleClick(command){
      if(command === 'cancel'){
        //清除Cookie中的token
        Cookie.remove('token')
        //清除Cookie中的Menu
        Cookie.remove('menu')
       //跳转到登录页面
       this.$router.push('/login')
      }
    }
  }
}
</script>
<style lang="less" scoped>
.header-container {
  background-color: #333;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  .text {
    color: #fff;
    font-size: 14px;
    margin-left: 10px;
  }
  .r-content {
    .userimg {
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
  }
  .l-content{
    display: flex;
    align-items: center;
    ::v-deep .el-breadcrumb__item{
      .el-breadcrumb__inner{
        font-weight: normal;
        &.is-link{
          color: #666;
        }
      }
      &:last-child{
        .el-breadcrumb__inner{
          color: #fff;
        }
      } 
    }
  }
}
</style>